package Test7;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Locale;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws Exception{
        BufferedReader kbin=new BufferedReader(new InputStreamReader(System.in));
        while(true){
            System.out.print("# ");
            String cmd=kbin.readLine();
            if(cmd.toLowerCase().equals("exit")){
                System.exit(0);
            }
            else if(cmd.toLowerCase().startsWith("ls")){
                Scanner scan=new Scanner(System.in);
                String src=scan.nextLine();
                FileSymstem fs=new FileSymstem();
                fs.achieveLS(cmd,src);
            }
            else if(cmd.toLowerCase().startsWith("cp")){
                Scanner scan1=new Scanner(System.in);
                String src=scan1.nextLine();
                Scanner scan2=new Scanner(System.in);
                String des=scan2.nextLine();
                FileSymstem fs=new FileSymstem();
                boolean ret=fs.copyFile(cmd,src,des);
                if(!ret){
                    System.out.println("文件不存在");
                }
            }
            else if(cmd.toLowerCase().startsWith("mv")){
                Scanner scan1=new Scanner(System.in);
                String src=scan1.nextLine();
                Scanner scan2=new Scanner(System.in);
                String des=scan2.nextLine();
                FileSymstem fs=new FileSymstem();
                boolean ret=fs.moveFile(cmd,src,des);
                if (!ret) {
                    System.out.println("文件不存在");
                }
            }
            else if(cmd.toLowerCase().startsWith("rm")){
                Scanner scan=new Scanner(System.in);
                String src=scan.nextLine();
                FileSymstem fs=new FileSymstem();
                boolean ret=fs.deleteFile(cmd,src);
                if (!ret) {
                    System.out.println("文件不存在");
                }
            }
            else if(cmd.toLowerCase().startsWith("md")){
                Scanner scan=new Scanner(System.in);
                String src=scan.nextLine();
                FileSymstem fs=new FileSymstem();
                boolean ret=fs.makeDir(cmd,src);
                if (!ret) {
                    System.out.println("文件不存在");
                }
            }
            else if(cmd.toLowerCase().startsWith("rd")){
                Scanner scan=new Scanner(System.in);
                String src=scan.nextLine();
                FileSymstem fs=new FileSymstem();
                boolean ret=fs.deleteDir(cmd,src);
                if (!ret) {
                    System.out.println("文件不存在");
                }
            }
            else if(cmd.toLowerCase().startsWith("cat")){
                Scanner scan=new Scanner(System.in);
                String src=scan.nextLine();
                FileSymstem fs=new FileSymstem();
                fs.achieveCat(cmd,src);
            }
            else{
                System.out.println("无法识别所输入的命令："+cmd);
            }
        }
    }
}
